package cloudoer.blog.controller;

import cloudoer.blog.base.BaseController;
import cloudoer.blog.entity.Tag;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/tag")
public class TagController extends BaseController{
    private static Logger logger = Logger.getLogger(TagController.class);

    @RequestMapping("/index")
    public String index(){
        return "admin/tag/index";
    }
    @RequestMapping("/addUI")
    public String addUI(){
        return "admin/tag/add";
    }
    @RequestMapping("/updateUI")
    public String updateUI(){
        return "admin/tag/update";
    }

    @RequestMapping("/getAll")
    @ResponseBody
    public Map<String, Object> getAll (){
        List<Tag> list = tagService.getAll();
        return getMap(list);
    }

    @RequestMapping("/add")
    @ResponseBody
    public Map<String, Object> add(Tag tag){
        tagService.add(tag);
        return success("添加成功");
    }

    @RequestMapping("/update")
    @ResponseBody
    public Map<String, Object> update (Tag tag){
        tagService.update(tag);
        return success("修改成功");
    }
    @RequestMapping("/delete")
    @ResponseBody
    public Map<String, Object> delete (String id){
        tagService.delete(id);
        return success("删除成功");
    }
}
